﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PigLatin
{
    class Program
    {
        static void Main(string[] args)
        {
            String input;
            Console.Write("English: ");

            input = Console.ReadLine();

            Console.WriteLine();

            Console.WriteLine("Pig Latin: " + translate(input));
        }

        private static string translate(string input)
        {
            String[] words = input.Split(' ');
            String newString = "";

            for (int i = 0; i < words.Length; i++)
            {
                String punctuation = "";

                if ((int)((words[i])[(words[i].Length - 1)]) > 32 && (int)((words[i])[(words[i].Length - 1)]) < 64)
                {
                    punctuation = ((words[i])[(words[i].Length - 1)]).ToString();

                    words[i] = words[i].Remove((words[i].Length - 1), 1);
                }

                if ((words[i].ToLower())[0] == 'a'
                    || (words[i].ToLower())[0] == 'e'
                    || (words[i].ToLower())[0] == 'i'
                    || (words[i].ToLower())[0] == 'o'
                    || (words[i].ToLower())[0] == 'u')
                {
                    words[i] += "way";
                }
                else if((words[i].ToLower())[0] == 'q' && (words[i].ToLower())[1] == 'u')
                {
                    words[i] = words[i].Remove(0, 2);

                    words[i] += "quay";
                }
                else
                {
                    char letter = (words[i].ToLower())[0];

                    words[i] = words[i].Remove(0,1);

                    words[i] = words[i] + letter + "ay";
                }

                newString = newString + words[i] + punctuation + " ";
            }

            char firstLetter = (newString.ToUpper())[0];

            newString = firstLetter + newString.Remove(0, 1);

            return newString;
        }
    }
}
